package com.hxzy.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author nick
 */
@WebServlet("/a")
public class ServletA extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取当前请求的请求方式
        String method = req.getMethod();
        System.out.println("当前请求方式为：" + method);
        System.out.println("/a request内存地址：" + req);

        req.setAttribute("gift","iphone");

        //页面转发；  /a  ->  /b
        req.getRequestDispatcher("/b").forward(req,resp);

    }
}
